flowchart TD
    Start([开始]) --> Login{用户登录}
    Login -->|未注册| Register[注册账号]
    Register --> RegisterRole{选择角色}
    RegisterRole -->|投标单位| RegisterBidder[注册为BIDDER<br/>填写公司信息]
    RegisterRole -->|招标单位| RegisterTenderer[注册为TENDERER<br/>填写公司信息]
    RegisterBidder --> Login
    RegisterTenderer --> Login
    Login -->|已注册| AuthCheck{验证身份}
    AuthCheck -->|成功| RoleCheck{用户角色}
    AuthCheck -->|失败| Login·
    
    RoleCheck -->|BIDDER<br/>投标单位| BidderDashboard[投标单位首页]
    RoleCheck -->|TENDERER<br/>招标单位| TendererDashboard[招标单位首页]
    RoleCheck -->|ADMIN<br/>管理员| AdminDashboard[管理员首页]
    
    %% 投标单位流程
    BidderDashboard --> ViewTenders[浏览招标信息]
    ViewTenders --> SelectTender[选择招标项目]
    SelectTender --> ViewTenderDetail[查看招标详情]
    ViewTenderDetail --> SubmitBid{提交投标}
    SubmitBid -->|填写投标信息| BidForm[填写投标表单<br/>产品批号/生产日期<br/>有效期/总金额等]
    BidForm --> SaveBid[保存投标信息]
    SaveBid --> MyBids[查看我的投标]
    ViewTenderDetail --> PostMessage[发布留言]
    ViewTenders --> Messages[留言板]
    Messages --> PostMessage
    
    %% 招标单位流程
    TendererDashboard --> CreateTender[发布招标]
    CreateTender --> TenderForm[填写招标表单<br/>招标编号/药品名称<br/>制药单位/包装要求<br/>总量/截止日期/保证金]
    TenderForm --> SaveTender[保存招标信息]
    SaveTender --> ViewTenders
    TendererDashboard --> ViewMyTenders[查看我的招标]
    ViewMyTenders --> ViewTenderBids[查看项目投标列表]
    ViewTenderBids --> ReviewBids[审核投标信息]
    TendererDashboard --> EditTender[编辑招标信息]
    EditTender --> TenderForm
    
    %% 管理员流程
    AdminDashboard --> UserManagement[用户管理]
    UserManagement --> ViewUsers[查看用户列表]
    ViewUsers --> ChangeRole[调整用户角色]
    ChangeRole --> UpdateRole[更新角色]
    UpdateRole --> ViewUsers
    AdminDashboard --> MessageManagement[留言管理]
    MessageManagement --> DeleteMessage[删除留言]
    DeleteMessage --> Messages
    AdminDashboard --> ViewTenders
    AdminDashboard --> ViewAllBids[查看所有投标]
    
    %% 通用流程
    PostMessage --> SaveMessage[保存留言]
    SaveMessage --> Messages
    MyBids --> End1([结束])
    ReviewBids --> End2([结束])
    ViewAllBids --> End3([结束])
    
    style Start fill:#e1f5ff
    style Login fill:#ffe1f5
    style Register fill:#fff5e1
    style BidderDashboard fill:#e1ffe1
    style TendererDashboard fill:#ffe1e1
    style AdminDashboard fill:#e1e1ff
    style End1 fill:#e1f5ff
    style End2 fill:#e1f5ff
    style End3 fill:#e1f5ff

